
import DragLimit from "./drag-limit";

/**
 * 自由拖动（无约束）
 */
export default class DragFreeLimit extends DragLimit{
    constructor(values){
        super(values);
    }
    get type(){
        return 'dragFreeLimit';
    }
    modifyMove(object,v,callback,camera) {
        let objectPosition = this._transformVector(object,v);
        if(this._freeSnapEnabled){
            let snap=this._freeSnapValue;
            let snapOfs=this._freeSnapOffset;
            let tempX=Math.round((objectPosition.x-snapOfs.x)/snap)*snap+snapOfs.x;
            let tempY=Math.round((objectPosition.y-snapOfs.y)/snap)*snap+snapOfs.y;
            let tempZ=Math.round((objectPosition.z-snapOfs.z)/snap)*snap+snapOfs.z;
            objectPosition.set(tempX,tempY,tempZ);
        }
        object.position.copy(objectPosition);
        if(!callback)return;
        callback(object,objectPosition);
    }
}